{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    1.0\n",
       "1    3.0\n",
       "2    5.0\n",
       "3    NaN\n",
       "4    6.0\n",
       "5    8.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## create a Series by passing a list of values, letting pandas create a default integer index\n",
    "\n",
    "s = pd.Series([1, 3, 5, np.nan, 6, 8])\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04',\n",
       "               '2013-01-05', '2013-01-06'],\n",
       "              dtype='datetime64[ns]', freq='D')"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## create a DataFrame by passing a numpy array, with a datetime index and labeled columns\n",
    "\n",
    "dates = pd.date_range('20130101', periods=6)\n",
    "dates"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>-0.345314</td>\n",
       "      <td>-1.213064</td>\n",
       "      <td>-0.607966</td>\n",
       "      <td>-0.851094</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>-0.204905</td>\n",
       "      <td>1.475389</td>\n",
       "      <td>0.341369</td>\n",
       "      <td>-0.313155</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>1.278420</td>\n",
       "      <td>1.442819</td>\n",
       "      <td>-0.419220</td>\n",
       "      <td>0.531115</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>0.610140</td>\n",
       "      <td>-0.159420</td>\n",
       "      <td>0.613996</td>\n",
       "      <td>0.352854</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-0.695667</td>\n",
       "      <td>0.320412</td>\n",
       "      <td>0.954720</td>\n",
       "      <td>-1.062654</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>-0.405611</td>\n",
       "      <td>-0.249739</td>\n",
       "      <td>0.241814</td>\n",
       "      <td>0.896514</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-01 -0.345314 -1.213064 -0.607966 -0.851094\n",
       "2013-01-02 -0.204905  1.475389  0.341369 -0.313155\n",
       "2013-01-03  1.278420  1.442819 -0.419220  0.531115\n",
       "2013-01-04  0.610140 -0.159420  0.613996  0.352854\n",
       "2013-01-05 -0.695667  0.320412  0.954720 -1.062654\n",
       "2013-01-06 -0.405611 -0.249739  0.241814  0.896514"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame(np.random.randn(6, 4),\n",
    "                 index = dates,\n",
    "                 columns = list('ABCD'))\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "      <th>E</th>\n",
       "      <th>F</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2013-01-02</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>test</td>\n",
       "      <td>foo</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>2013-01-02</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>train</td>\n",
       "      <td>foo</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>2013-01-02</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>test</td>\n",
       "      <td>foo</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>2013-01-02</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>train</td>\n",
       "      <td>foo</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A          B    C    D      E    F\n",
       "0  1 2013-01-02  1.0  3.0   test  foo\n",
       "1  1 2013-01-02  1.0  3.0  train  foo\n",
       "2  1 2013-01-02  1.0  3.0   test  foo\n",
       "3  1 2013-01-02  1.0  3.0  train  foo"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## create a DataFrame by passing a dict of objects that can be converted to series-like\n",
    "\n",
    "df2 = pd.DataFrame({\n",
    "    'A': 1,\n",
    "    'B': pd.Timestamp('20130102'),\n",
    "    'C': pd.Series(1, index=list(range(4)), dtype='float32'),\n",
    "    'D': np.array([3] * 4, dtype='float32'),\n",
    "    'E': pd.Categorical(['test', 'train', 'test', 'train']),\n",
    "    'F': 'foo'\n",
    "})\n",
    "\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A             int64\n",
       "B    datetime64[ns]\n",
       "C           float32\n",
       "D           float32\n",
       "E          category\n",
       "F            object\n",
       "dtype: object"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>-0.345314</td>\n",
       "      <td>-1.213064</td>\n",
       "      <td>-0.607966</td>\n",
       "      <td>-0.851094</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>-0.204905</td>\n",
       "      <td>1.475389</td>\n",
       "      <td>0.341369</td>\n",
       "      <td>-0.313155</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>1.278420</td>\n",
       "      <td>1.442819</td>\n",
       "      <td>-0.419220</td>\n",
       "      <td>0.531115</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>0.610140</td>\n",
       "      <td>-0.159420</td>\n",
       "      <td>0.613996</td>\n",
       "      <td>0.352854</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-0.695667</td>\n",
       "      <td>0.320412</td>\n",
       "      <td>0.954720</td>\n",
       "      <td>-1.062654</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-01 -0.345314 -1.213064 -0.607966 -0.851094\n",
       "2013-01-02 -0.204905  1.475389  0.341369 -0.313155\n",
       "2013-01-03  1.278420  1.442819 -0.419220  0.531115\n",
       "2013-01-04  0.610140 -0.159420  0.613996  0.352854\n",
       "2013-01-05 -0.695667  0.320412  0.954720 -1.062654"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>0.610140</td>\n",
       "      <td>-0.159420</td>\n",
       "      <td>0.613996</td>\n",
       "      <td>0.352854</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-0.695667</td>\n",
       "      <td>0.320412</td>\n",
       "      <td>0.954720</td>\n",
       "      <td>-1.062654</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>-0.405611</td>\n",
       "      <td>-0.249739</td>\n",
       "      <td>0.241814</td>\n",
       "      <td>0.896514</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-04  0.610140 -0.159420  0.613996  0.352854\n",
       "2013-01-05 -0.695667  0.320412  0.954720 -1.062654\n",
       "2013-01-06 -0.405611 -0.249739  0.241814  0.896514"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.tail(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04',\n",
       "               '2013-01-05', '2013-01-06'],\n",
       "              dtype='datetime64[ns]', freq='D')"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['A', 'B', 'C', 'D'], dtype='object')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.34531375, -1.21306383, -0.60796627, -0.85109412],\n",
       "       [-0.20490493,  1.47538916,  0.34136942, -0.31315529],\n",
       "       [ 1.27842018,  1.44281867, -0.41921963,  0.53111522],\n",
       "       [ 0.61013986, -0.15942046,  0.61399577,  0.35285425],\n",
       "       [-0.69566686,  0.32041158,  0.95472026, -1.06265424],\n",
       "       [-0.40561131, -0.24973876,  0.24181444,  0.89651368]])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>6.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>6.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>0.039511</td>\n",
       "      <td>0.269399</td>\n",
       "      <td>0.187452</td>\n",
       "      <td>-0.074403</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.749261</td>\n",
       "      <td>1.047379</td>\n",
       "      <td>0.599671</td>\n",
       "      <td>0.791046</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>-0.695667</td>\n",
       "      <td>-1.213064</td>\n",
       "      <td>-0.607966</td>\n",
       "      <td>-1.062654</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>-0.390537</td>\n",
       "      <td>-0.227159</td>\n",
       "      <td>-0.253961</td>\n",
       "      <td>-0.716609</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>-0.275109</td>\n",
       "      <td>0.080496</td>\n",
       "      <td>0.291592</td>\n",
       "      <td>0.019849</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>0.406379</td>\n",
       "      <td>1.162217</td>\n",
       "      <td>0.545839</td>\n",
       "      <td>0.486550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>1.278420</td>\n",
       "      <td>1.475389</td>\n",
       "      <td>0.954720</td>\n",
       "      <td>0.896514</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              A         B         C         D\n",
       "count  6.000000  6.000000  6.000000  6.000000\n",
       "mean   0.039511  0.269399  0.187452 -0.074403\n",
       "std    0.749261  1.047379  0.599671  0.791046\n",
       "min   -0.695667 -1.213064 -0.607966 -1.062654\n",
       "25%   -0.390537 -0.227159 -0.253961 -0.716609\n",
       "50%   -0.275109  0.080496  0.291592  0.019849\n",
       "75%    0.406379  1.162217  0.545839  0.486550\n",
       "max    1.278420  1.475389  0.954720  0.896514"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2013-01-01 00:00:00</th>\n",
       "      <th>2013-01-02 00:00:00</th>\n",
       "      <th>2013-01-03 00:00:00</th>\n",
       "      <th>2013-01-04 00:00:00</th>\n",
       "      <th>2013-01-05 00:00:00</th>\n",
       "      <th>2013-01-06 00:00:00</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>-0.345314</td>\n",
       "      <td>-0.204905</td>\n",
       "      <td>1.278420</td>\n",
       "      <td>0.610140</td>\n",
       "      <td>-0.695667</td>\n",
       "      <td>-0.405611</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>-1.213064</td>\n",
       "      <td>1.475389</td>\n",
       "      <td>1.442819</td>\n",
       "      <td>-0.159420</td>\n",
       "      <td>0.320412</td>\n",
       "      <td>-0.249739</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>-0.607966</td>\n",
       "      <td>0.341369</td>\n",
       "      <td>-0.419220</td>\n",
       "      <td>0.613996</td>\n",
       "      <td>0.954720</td>\n",
       "      <td>0.241814</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>-0.851094</td>\n",
       "      <td>-0.313155</td>\n",
       "      <td>0.531115</td>\n",
       "      <td>0.352854</td>\n",
       "      <td>-1.062654</td>\n",
       "      <td>0.896514</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   2013-01-01  2013-01-02  2013-01-03  2013-01-04  2013-01-05  2013-01-06\n",
       "A   -0.345314   -0.204905    1.278420    0.610140   -0.695667   -0.405611\n",
       "B   -1.213064    1.475389    1.442819   -0.159420    0.320412   -0.249739\n",
       "C   -0.607966    0.341369   -0.419220    0.613996    0.954720    0.241814\n",
       "D   -0.851094   -0.313155    0.531115    0.352854   -1.062654    0.896514"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>D</th>\n",
       "      <th>C</th>\n",
       "      <th>B</th>\n",
       "      <th>A</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>-0.851094</td>\n",
       "      <td>-0.607966</td>\n",
       "      <td>-1.213064</td>\n",
       "      <td>-0.345314</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>-0.313155</td>\n",
       "      <td>0.341369</td>\n",
       "      <td>1.475389</td>\n",
       "      <td>-0.204905</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>0.531115</td>\n",
       "      <td>-0.419220</td>\n",
       "      <td>1.442819</td>\n",
       "      <td>1.278420</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>0.352854</td>\n",
       "      <td>0.613996</td>\n",
       "      <td>-0.159420</td>\n",
       "      <td>0.610140</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-1.062654</td>\n",
       "      <td>0.954720</td>\n",
       "      <td>0.320412</td>\n",
       "      <td>-0.695667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>0.896514</td>\n",
       "      <td>0.241814</td>\n",
       "      <td>-0.249739</td>\n",
       "      <td>-0.405611</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   D         C         B         A\n",
       "2013-01-01 -0.851094 -0.607966 -1.213064 -0.345314\n",
       "2013-01-02 -0.313155  0.341369  1.475389 -0.204905\n",
       "2013-01-03  0.531115 -0.419220  1.442819  1.278420\n",
       "2013-01-04  0.352854  0.613996 -0.159420  0.610140\n",
       "2013-01-05 -1.062654  0.954720  0.320412 -0.695667\n",
       "2013-01-06  0.896514  0.241814 -0.249739 -0.405611"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_index(axis=1, ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>-0.345314</td>\n",
       "      <td>-1.213064</td>\n",
       "      <td>-0.607966</td>\n",
       "      <td>-0.851094</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>-0.405611</td>\n",
       "      <td>-0.249739</td>\n",
       "      <td>0.241814</td>\n",
       "      <td>0.896514</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>0.610140</td>\n",
       "      <td>-0.159420</td>\n",
       "      <td>0.613996</td>\n",
       "      <td>0.352854</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-0.695667</td>\n",
       "      <td>0.320412</td>\n",
       "      <td>0.954720</td>\n",
       "      <td>-1.062654</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>1.278420</td>\n",
       "      <td>1.442819</td>\n",
       "      <td>-0.419220</td>\n",
       "      <td>0.531115</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>-0.204905</td>\n",
       "      <td>1.475389</td>\n",
       "      <td>0.341369</td>\n",
       "      <td>-0.313155</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-01 -0.345314 -1.213064 -0.607966 -0.851094\n",
       "2013-01-06 -0.405611 -0.249739  0.241814  0.896514\n",
       "2013-01-04  0.610140 -0.159420  0.613996  0.352854\n",
       "2013-01-05 -0.695667  0.320412  0.954720 -1.062654\n",
       "2013-01-03  1.278420  1.442819 -0.419220  0.531115\n",
       "2013-01-02 -0.204905  1.475389  0.341369 -0.313155"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_values(by='B')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2013-01-01   -0.345314\n",
       "2013-01-02   -0.204905\n",
       "2013-01-03    1.278420\n",
       "2013-01-04    0.610140\n",
       "2013-01-05   -0.695667\n",
       "2013-01-06   -0.405611\n",
       "Freq: D, Name: A, dtype: float64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## Secletion, .at, .iat, .loc, .iloc, .ix\n",
    "\n",
    "df['A']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "## Missing data: np.nan "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>-0.690627</td>\n",
       "      <td>-2.426128</td>\n",
       "      <td>-1.215933</td>\n",
       "      <td>-1.702188</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>-0.409810</td>\n",
       "      <td>2.950778</td>\n",
       "      <td>0.682739</td>\n",
       "      <td>-0.626311</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>2.556840</td>\n",
       "      <td>2.885637</td>\n",
       "      <td>-0.838439</td>\n",
       "      <td>1.062230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>1.220280</td>\n",
       "      <td>-0.318841</td>\n",
       "      <td>1.227992</td>\n",
       "      <td>0.705708</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-1.391334</td>\n",
       "      <td>0.640823</td>\n",
       "      <td>1.909441</td>\n",
       "      <td>-2.125308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>-0.811223</td>\n",
       "      <td>-0.499478</td>\n",
       "      <td>0.483629</td>\n",
       "      <td>1.793027</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-01 -0.690627 -2.426128 -1.215933 -1.702188\n",
       "2013-01-02 -0.409810  2.950778  0.682739 -0.626311\n",
       "2013-01-03  2.556840  2.885637 -0.838439  1.062230\n",
       "2013-01-04  1.220280 -0.318841  1.227992  0.705708\n",
       "2013-01-05 -1.391334  0.640823  1.909441 -2.125308\n",
       "2013-01-06 -0.811223 -0.499478  0.483629  1.793027"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
